package operation;

import book.bookList;

import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/7/13 15:33
 * 查找图书
 */
public class FindOperation implements IOperation{

    @Override
    public void work(bookList booklist) {
        System.out.println("查找图书");

        System.out.println("请输入你要查找图书的书名");
        Scanner sc = new Scanner(System.in);
        String bookName = sc.nextLine();

        for (int i = 0; i < booklist.getCount(); i++) {
            if (bookName.equals(booklist.getBooks(i).getName())){
                //如果存在这本书，就打印这本书的信息，然后退出系统
                System.out.println("找到了"+ "《"+ bookName + "》");
                System.out.println(booklist.getBooks(i));
                return;
            }
        }
        //若未找到图书，就说明没找到
        System.out.println("未找到"+ "《"+ bookName + "》");
    }
}
